/**
 * Created by 王子恒 on 2017/7/5.
 */
(function(window){
    if(!window["XComponent"]){
        throw new Error("it must depend on component.js");
    }
    function tuwen(options){
        XComponent.call(this,options);
        render.call(this);
        this.setTitle(options["title"])
        this.setTitle(options["content"])
        this._addShadow();
        bindEvent.call(this);
    }

    function render(){
        this.mainDom = this.doc.createElement("div");
        this.mainDom.className = "xtuwen part";
        this.titleDom = this.doc.createElement("div");
        this.mainDom.appendChild(this.titleDom);
        this.titleDom.className = "xtuwen_title";
        this.contentDom = this.doc.createElement("div");
        this.mainDom.appendChild(this.contentDom);
        this.contentDom.className = "xtuwen_content";
    }

    function bindEvent(){
        var self = this;
        $(this.mainDom).click(function(){
            self.showComponentEditor();
        });
    }


    var XComponent =  window["XComponent"];

    XComponent.extend(tuwen);
    tuwen.icon = "iconfont icon-tuwen";
    tuwen.caption = "图文";

    tuwen.prototype.getParentDom = function(){
        return this.mainDom;
    }

    tuwen.prototype.setTitle = function(title){
        if(title == null) return;
        this.title = title;
        this.titleDom.innerText = title;
    }
    tuwen.prototype.setContent = function(content){
        if(content == null) return;
        this.content = content;
        this.contentDom.innerHTML = content;
    }


    window["XComponent"].tuwen = tuwen;
})(window);